import { Controller, HttpCode, HttpStatus, Post, Req } from '@nestjs/common';
import { ApiOperation } from '@nestjs/swagger';
import { EmailService } from './email.service';
import { Request } from 'express';
import { GLOBAL_CONSTANTS } from 'src/global/constants';

@Controller('email')
export class EmailController {
  constructor(private readonly emailService: EmailService) {}

  @ApiOperation({ summary: '测试发送邮件' })
  @HttpCode(HttpStatus.OK)
  @Post('herry')
  email(@Req() request: Request) {
    // 获取Authorization头部的token
    return this.emailService.sendEmail(
      GLOBAL_CONSTANTS.MY_SELF_EMAIL,
      'Hello',
      request.headers.authorization,
    );
  }
}
